package lcr;

public class Test0052 {

}

class Solution0052_1 {
    TreeNode head;
    TreeNode tail;
    public TreeNode increasingBST(TreeNode root) {
        dfs(root);
        return head;
    }

    public void dfs(TreeNode node) {
        if (node.left!=null) dfs(node.left);
        if (head==null) head = node;
        else tail.right = node;
        tail = node;
        if (node.right!=null) dfs(node.right);
        node.left = null;
    }
}
